var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0}), (o.ClickClick = void 0);
var a = t("BootConst"),
    i = t("ConfS"),
    s = t("Const"),
    c = t("Platforms"),
    l = t("Popup"),
    u = t("Sounds"),
    p = t("TableRules"),
    f = t("WatchVideo"),
    d = cc._decorator,
    h = d.ccclass,
    y =
        (d.property,
        (function (t) {
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                return (
                    (e.step = function () {
                        switch (e.status) {
                            case "没点击":
                                (e.progress -= 0.01) < 0 && (e.progress = 0);
                                break;
                            case "点击":
                                e.status = "没点击";
                                break;
                            case "自动打开":
                                (e.progress += i.DatasManager.胜利宝箱系数4) > 1 && (e.progress = 1);
                        }
                        e.entry.trackTime = e.progress * e.entry.animation.duration;
                    }),
                    e
                );
            }
            return (
                n(e, t),
                (e.prototype.init = function () {
                    var t = this,
                        e = this.node.getChildByName("container"),
                        o = e.getChildByName("bottom");
                    (this.title1 = e.getChildByName("title1").getComponent(cc.Label)),
                        (this.title2 = e.getChildByName("title2").getComponent(cc.Label)),
                        (this.btn = o.getChildByName("btn")),
                        this.btn.on(cc.Node.EventType.TOUCH_START, function () {
                            u.Sounds.playFX("点击"),
                                t.hand.active
                                    ? ((t.hand.active = !1),
                                      (t.entry = c.default.playAnimation(t.chest, "player2", !1)),
                                      c.default.enterFrames.add(t.step),
                                      (t.status = "没点击"),
                                      (t.progress = 0))
                                    : "自动打开" == t.status ||
                                      ((t.progress += (1 - t.progress) * i.DatasManager.胜利宝箱系数1),
                                      t.progress >= i.DatasManager.胜利宝箱系数2 &&
                                      Math.random() < i.DatasManager.胜利宝箱系数3
                                          ? ((t.status = "自动打开"),
                                            p.TableRules.show(t.node, "胜利宝箱"),
                                            c.default.delays.delay({
                                                time: i.DatasManager.胜利宝箱延时1,
                                                action: function () {
                                                    c.default.enterFrames.clear(t.step),
                                                        (t.chest.timeScale = 1),
                                                        c.default.playAnimation(t.chest, "player3", !1),
                                                        c.default.delays.delay({
                                                            time: i.DatasManager.胜利宝箱延时2,
                                                            action: function () {
                                                                (t.progress = 1),
                                                                    (t.chest.node.active = !1),
                                                                    (t.btn.active = !1),
                                                                    (t.coin.active = !0),
                                                                    c.default.调整视频按钮们(
                                                                        t.lingqu,
                                                                        t.lingqu小,
                                                                        t.watchVideo
                                                                    );
                                                            }
                                                        });
                                                }
                                            }))
                                          : (t.status = "点击"));
                        }),
                        (this.hand = o.getChildByName("手")),
                        (this.hand.active = !1),
                        (this.chest = e.getChildByName("chest").getComponent(sp.Skeleton)),
                        (this.coin = e.getChildByName("coin")),
                        (this.coins = this.coin.getChildByName("coins").getComponent(cc.Label)),
                        (this.coins.string = "x" + i.DatasManager.宝箱奖励金币数),
                        (this.lingqu = e.getChildByName("lingqu")),
                        this.lingqu.on(cc.Node.EventType.TOUCH_START, function () {
                            u.Sounds.playFX("点击"), t.领取奖励(1);
                        }),
                        (this.lingqu小 = e.getChildByName("lingqu小")),
                        this.lingqu小.on(cc.Node.EventType.TOUCH_START, function () {
                            u.Sounds.playFX("点击"), t.领取奖励(1);
                        }),
                        (this.watchVideo = e.getChildByName("watchVideo")),
                        this.watchVideo.on(cc.Node.EventType.TOUCH_END, function () {
                            f.default.show(a.dd.clickClick, function () {
                                t.领取奖励(2);
                            });
                        }),
                        s.default.wid0 > s.default.hei0 || ((e.width = 640), (e.height = s.default.stageHei));
                }),
                (e.prototype.setTitle = function (t) {
                    this.title1.string = this.title2.string = t;
                }),
                (e.prototype.领取奖励 = function (t) {
                    var e = this;
                    s.default.addMoney(
                        "金币",
                        i.DatasManager.宝箱奖励金币数 * t,
                        "误触" + t + "倍领取",
                        this.coin,
                        function () {
                            e.hide(), e.callback();
                        }
                    ),
                        (this.coin.active = !1),
                        (this.lingqu.active = !1),
                        (this.lingqu小.active = !1),
                        (this.watchVideo.active = !1);
                }),
                (e.prototype.show = function () {
                    t.prototype.show.call(this),
                        (this.status = "没点击"),
                        (this.progress = 0),
                        (this.chest.node.active = !0),
                        (this.chest.timeScale = 0),
                        (this.coin.active = !1),
                        (this.lingqu.active = !1),
                        (this.lingqu小.active = !1),
                        (this.watchVideo.active = !1),
                        (this.btn.active = !0),
                        (this.hand.active = !0),
                        c.default.playAnimation(this.chest, "player1", !1),
                        (this.entry = null);
                }),
                (e.prototype.showComplete = function () {
                    t.prototype.showComplete.call(this);
                }),
                (e.prototype.hide = function () {
                    t.prototype.hide.call(this), p.TableRules.hide(this.node, "胜利宝箱");
                }),
                (e.prototype.hideComplete = function () {
                    t.prototype.hideComplete.call(this);
                }),
                (e = r([h], e))
            );
        })(l.Popup));
o.ClickClick = y;
